package com.fasttreatment.zzr.demo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.android.androidlibrary.base.SimpleRecAdapter;
import com.android.androidlibrary.imageloader.ILoader;
import com.android.androidlibrary.imageloader.ImageFactory;
import com.android.androidlibrary.util.KnifeUtil;
import com.fasttreatment.zzr.demo.R;
import com.fasttreatment.zzr.demo.model.GankEntity;

import butterknife.BindView;

/**
 * Created by zzr on 17/1/10.
 */

public class GirlAdapter extends SimpleRecAdapter<GankEntity.Item, GirlAdapter.ViewHolder> {
    private Context mContext;
    public static final int TAG_VIEW = 0;
    public GirlAdapter(Context context) {
        super(context);
        mContext = context;
    }

    @Override
    public ViewHolder newViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }

    @Override
    public int getLayoutId() {
        return R.layout.girl_item;
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position) {
        final GankEntity.Item item = data.get(position);
        ImageFactory.getLoader().loadNet(
                holder.ivGirl,item.getUrl(),new ILoader.Options(R.mipmap.ic_launcher,R.mipmap.ic_launcher,2,20));

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (getRecItemClick() != null) {
                    getRecItemClick().onItemClick(position, item, TAG_VIEW, holder);
                }
            }
        });
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_girl)
        ImageView ivGirl;


        public ViewHolder(View itemView) {
            super(itemView);
            KnifeUtil.bind(this, itemView);
        }
    }
}
